#!/usr/bin/env python
# encoding: utf-8
'''
@author: wangjianrong
@software: pycharm
@file: io密集型.py
@time: 2020/10/12 10:56
@desc:
'''

#
# import multiprocessing
# import threading
# import time
#
#
# def count(num):
#     time.sleep(1)  ## 模拟IO操作
#     print("Process {0} End".format(num))
#
#
# if __name__ == '__main__':
#     start_time = time.time()
#     process = list()
#     for i in range(5):
#         p = multiprocessing.Process(target=count, args=(i,))
#         # p = threading.Thread(target=count, args=(i,))
#         process.append(p)
#
#     for p in process:
#         p.start()
#
#     for p in process:
#         p.join()
#
#     end_time = time.time()
#     print("Total time:{0}".format(end_time - start_time))







#
# async def coroutine():
#     await asyncio.sleep(1) ## 模拟IO操作
#
#
# if __name__ == "__main__":
#     start_time = time.time()
#
#     loop = asyncio.get_event_loop()
#     tasks = []
#     for i in range(5):
#         task = loop.create_task(coroutine())
#         tasks.append(task)
#
#     loop.run_until_complete(asyncio.wait(tasks))
#     loop.close()
#     end_time = time.time()
#     print("total time:", end_time - start_time)